﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace QuanLy_NhaSach
{
    public partial class Theloai : Form
    {
        public Theloai()
        {
            InitializeComponent();
        }

        private void loaiSachBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            this.Validate();
            this.loaiSachBindingSource.EndEdit();
            this.tableAdapterManager.UpdateAll(this.nhaSachDataSet);

        }

        private void Theloai_Load(object sender, EventArgs e)
        {
            loaiSachBindingSource.DataSource = NhaSachBUS.LoaiSachBUS.LoadLoaiSach();
            txtmaloai.Text = HeThong.Const.GetID.ToString();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            CloseForm();
        }

        private void CloseForm()
        {
            this.Dispose();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                NhaSachBUS.LoaiSachBUS.XoaLoaiSach(maLoaiTextBox.Text);
                loaiSachBindingSource.DataSource = NhaSachBUS.LoaiSachBUS.LoadLoaiSach();
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
          NhaSachBUS.LoaiSachBUS.ThemLoaiSach(txtmaloai.Text, txttenloai.Text);
          loaiSachBindingSource.DataSource = NhaSachBUS.LoaiSachBUS.LoadLoaiSach();
          txtmaloai.Text = HeThong.Const.GetID.ToString();
        }

        private void tabPage2_Click(object sender, EventArgs e)
        {

        }

        private void button3_Click(object sender, EventArgs e)
        {
            NhaSachBUS.LoaiSachBUS.CapNhatLoaiSach(maLoaiTextBox.Text, tenLoaiTextBox.Text);
            loaiSachBindingSource.DataSource = NhaSachBUS.LoaiSachBUS.LoadLoaiSach();
        }

        private void loaiSachDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        private void loaiSachBindingNavigator_RefreshItems(object sender, EventArgs e)
        {

        }
    }
}
